<?php
namespace Intendant\Controller;
use Think\Controller;
class ContentComController extends Controller{
	public function _initialize()
    {
        if(!isset($_SESSION['admin_uid']))
        {
            $this->redirect('Login/index');
        }
    }
    //添加栏目时验证是否已存在栏目名称
	public function checkAddCate(){
		if(IS_POST && I('name')){
			$count = M("category")->where(array("name"=>I("name")))->count();
			if(!$count){
				echo 'true';
			} else {
				echo 'false';
			}
			exit;
		}
	}
	//修改栏目时验证是否已存在栏目名称
	public function checkEditCate(){
		if(IS_POST && I('name')){
			$where = array(
				'id' => array('neq',I("get.id")),
				'name' => I("name")
			);
			$cate = M("category");
			$count = $cate->where($where)->count();
			if(!$count){
				echo 'true';
			} else {
				echo 'false';
			}
			exit;
		}
	}
}